package ar.edu.utn.frsf.tpae.a2013.g04.persistence.dao;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

public class DBConnection {
	
	private String DB_URL;
	private String DB_USER;
	private String DB_PASS;
	
	private Statement statement;
	private Connection connection;
	
	public Connection getConnection() throws SQLException, ClassNotFoundException{
		if(connection == null){
		    Class.forName("org.postgresql.Driver");
		    this.connection = DriverManager.getConnection(DB_URL,DB_USER,DB_PASS);
		}
        return connection;
	}
	
	public Statement getStatement() throws SQLException, ClassNotFoundException{
		if(statement == null)
			statement = this.getConnection().createStatement();
		return statement;
	}
	
	public String getDB_URL() {
		return DB_URL;
	}

	public void setDB_URL(String dB_URL) {
		DB_URL = dB_URL;
	}

	public String getDB_USER() {
		return DB_USER;
	}
	public void setDB_USER(String dB_USER) {
		DB_USER = dB_USER;
	}
	public String getDB_PASS() {
		return DB_PASS;
	}
	public void setDB_PASS(String dB_PASS) {
		DB_PASS = dB_PASS;
	}

}
